package com.ving.test;

import com.ving.test.nativemybatis.entity.TestBean;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * Hello world!
 *
 */

public class App 
{
    public static void main( String[] args ) throws IOException {
        System.out.println( "Hello World!" );

        String resource = "mybatis/mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        TestBean testBean = (TestBean) sqlSession.selectOne("com.ving.mybatis.TestMapper.selectBlog", 4);
        System.out.println(testBean);
    }
}
